package com.artisan.biz.service;

import com.artisan.biz.factory.PluginFactory;
import com.artisan.spi.StorePlugin;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.File;

@Service
public class FileStoreService {

    @Value("plugin.type")
    private String type;

    @Resource
    private DefaultStoreService defaultStoreService;

    public void saveFile(String type) {
        StorePlugin targetPlugin = PluginFactory.getTargetPlugin(type);

        if (targetPlugin == null) {
            defaultStoreService.defaultSave(new File("/a"));
            return;
        }

        targetPlugin.saveFile(new File("/a"));
    }
}
